<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学员信息修改</title>
    <link rel="stylesheet" href="../../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/okadmin.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>学员信息修改</legend>
</fieldset>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <div class="layui-inline">
                        <label class="layui-form-label">I&#12288;&#12288;&#12288;D</label>
                        <div class="layui-input-block ">
                            <input type="text" id="studentId" name="studentId" lay-verify="required"
                                   style="background-color: #dcdcdc" disabled
                                   placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-inline">
                        <label class="layui-form-label">姓&#12288;&#12288;名</label>
                        <div class="layui-input-block ">
                            <input id="fullname" name="fullname" type="text" style="float: left;position: relative;"
                                   class="layui-input"
                                   placeholder="" lay-verify="required" autocomplete="off">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <div class="layui-inline">
                        <label class="layui-form-label">电&#12288;&#12288;话</label>
                        <div class="layui-input-block ">
                            <input id="phone" name="phone" type="text" style="float: left;position: relative;"
                                   class="layui-input"
                                   placeholder="" lay-verify="phone" autocomplete="off">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-inline">
                        <label class="layui-form-label">性&#12288;&#12288;别</label>
                        <div class="layui-input-block">
                            <input type="radio" name="agender" id="agender0" value="0" title="女" checked>
                            <input type="radio" name="agender" id="agender1" value="1" title="男">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <div class="layui-inline">
                        <label class="layui-form-label">邮&#12288;&#12288;箱</label>
                        <div class="layui-input-block ">
                            <input id="email" name="email" type="text" style="float: left;position: relative;"
                                   class="layui-input"
                                   placeholder="" lay-verify="email" autocomplete="off">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-inline" style="margin-left: 40%">
                        <button class="layui-btn layui-btn-normal layuiadmin-btn-list" lay-submit id="update" lay-filter="updateStudent">
                            更改
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/application.js"></script>
<script>
    function init(){
        htmlSetValue("studentId")
        htmlSetValue("fullname")
        htmlSetValue("phone")
        htmlSetValue("agender",function(value){
            if(value=='false'){
                $("#agender0").prop('checked',true);
            }else if(value=='true'){
                $("#agender1").prop('checked',true);
            }
        })
        htmlSetValue("email")
        htmlSetValue("students")
        htmlSetValue("remainingClassHours")
    }
    layui.use('form', function () {
        var form = layui.form;
        init()
        form.render();

        //监听提交
        form.on('submit(updateStudent)', function(data){
            layer.confirm("确定修改", function (index) {
                var data = {
                    studentId: getVal("studentId"),
                    fullname: getVal("fullname"),
                    phone: getVal("phone"),
                    agender: $('input[name="agender"]:checked').val(),
                    email: getVal("email")
                }
                myAjax(mainUri + "/student/update", data, function (d) {
                    if (d['code'] == 0) {
                        window.sessionStorage.setItem("user", JSON.stringify(d['data']));
                        layer.msg(d['msg'], {
                            icon: 1, time: 1500, end: function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index);//关闭当前iframe
                            }
                        })
                    }
                })
            })
            return false;
        });
    });
</script>
</html>